/*
 * uart.h
 *
 *  Created on: Jun 4, 2014
 *      Author: Administrator
 */

#ifndef UART_H_
#define UART_H_
#include "../hal_include/hal_types.h"
#ifdef __R8C
#include "../bsp/arch/r8c/sfr_r82d.h"

//#define uart0_send_byte(data) {while(!ti_u0c1);u0tbl = (data);}
#define uart1_send_byte(data) {while(!ti_u1c1);u1tbl = (data);}
//#define uart2_send_byte(data) {while(!ti_u2c1);u2tbl = (data);}
#define uart0_nodelay_send_byte(data) {u0tbl = (data);}
#define uart1_nodelay_send_byte(data) {u1tbl = (data);}
#define uart2_nodelay_send_byte(data) {u2tbl = (data);}
#endif
#ifdef __STM32
#endif

#define default_send_byte(data) uart0_send_byte(data)
#define default_nodelay_send_byte(data) uart0_nodelay_send_byte(data)

#define send_byte(data)	default_send_byte(data)
#define nodelay_send_byte(data)	 default_nodelay_send_byte(data)

#define enable_send_byte() enable_uart0_send()

#define debug_send_byte(data) uart1_send_byte(data)
#define debug_nodelay_send_byte(data) uart1_nodelay_send_byte(data)

#define UART_TX_MAX_LEN 100

typedef struct {
    uint8 tx_data_len;
    uint8 tx_data[ UART_TX_MAX_LEN ];
    uint8 tx_done;
}uart_tx_buffer;

extern void uart0_send_byte(uint8 data); 
extern void enable_uart0_send(void); 
extern void uart2_send_byte(uint8 data); 
extern void enable_uart2_send(void); 
extern void uart0_init(void);
extern void uart1_init(void);
extern void uart2_init(void);

#endif /* UART_H_ */
